package com.boot.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.boot.entity.Area;
import com.boot.mapper.AreaDao;
import com.boot.service.AreaService;
import com.boot.util.AdResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AreaServiceImpl extends ServiceImpl<AreaDao, Area> implements AreaService {

	@Resource
	private AreaDao areaDao;
	
	@Override
	public AdResult getArea() {
		AdResult result=new AdResult();
		List<Area> areas=areaDao.getArea();
		if(areas!=null && areas.size()>0){
			//说明有数据
			result.setData(areas);
			result.setMsg("获取成功");
			result.setStatus(1);
		}else{
			result.setMsg("获取失败");
			result.setStatus(0);
		}
		return result;
	}
	
	
	public AdResult getAreaCitys(String province){
		AdResult result=new AdResult();
		List<Area> areas=areaDao.getAreaCitys(province);
		if(areas!=null && areas.size()>0){
			//说明有数据
			result.setData(areas);
			result.setMsg("获取成功");
			result.setStatus(1);
		}else{
			result.setMsg("获取失败");
			result.setStatus(0);
		}
		return result;
	}


	@Override
	public AdResult getAreaDistricts(String areacode) {
		AdResult result=new AdResult();
		List<Area> areas=areaDao.getAreaDistricts(areacode);
		if(areas!=null && areas.size()>0){
			//说明有数据
			result.setData(areas);
			result.setMsg("获取成功");
			result.setStatus(1);
		}else{
			result.setMsg("获取失败");
			result.setStatus(0);
		}
		return result;
	}


	@Override
	public AdResult getAreaTowns(String areacode) {
		AdResult result=new AdResult();
		List<Area> areas=areaDao.getAreaTowns(areacode);
		if(areas!=null && areas.size()>0){
			//说明有数据
			result.setData(areas);
			result.setMsg("获取成功");
			result.setStatus(1);
		}else{
			result.setMsg("获取失败");
			result.setStatus(0);
		}
		return result;
	}

}
